package me.hgj.jetpackmvvm.util

import com.tencent.mmkv.MMKV

/**
 * @projectName
 * @author
 * @description:
 * @date : 2023/12/25 16:20
 * @version 1.0.0
 */
object MmkvUtil {

    //    fun mMkvWithID(keyName: String):MMKV {
//        return MMKV.mmkvWithID(keyName)
//    }
    fun clear() {
        MMKV.mmkvWithID("user")?.clearAll()
    }

    fun getUser(): String {
        val kv = MMKV.mmkvWithID("vq")
        val userStr = kv.decodeString("user")
        return userStr
    }


    fun setUser(): MMKV {
        val kv = MMKV.mmkvWithID("vq")
        return kv
    }

    fun  isLogin():Boolean{
        val kv = MMKV.mmkvWithID("vq")
        return kv.decodeBool("login", false)
    }

    fun setIsLogin(isLogin: Boolean){
        val kv = MMKV.mmkvWithID("vq")
        kv.encode("login", isLogin)
    }

    fun setIsAgree(isLogin: Boolean){
        val kv = MMKV.mmkvWithID("vq")
        kv.encode("agree", isLogin)
    }

    fun isAgree():Boolean{
        val kv = MMKV.mmkvWithID("vq")
        return kv.decodeBool("agree", false)
    }

}